package com.zjlp.im.netty.handler;

import io.netty.buffer.ByteBufUtil;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.http.DefaultHttpContent;

/**
 * Created by Administrator on 2016/12/8.
 */
public class MyHttpContentHandler extends SimpleChannelInboundHandler<DefaultHttpContent>{
    /**
     * <strong>Please keep in mind that this method will be renamed to
     * {@code messageReceived(ChannelHandlerContext, I)} in 5.0.</strong>
     * <p>
     * Is called for each message of type {@link I}.
     *
     * @param ctx the {@link io.netty.channel.ChannelHandlerContext} which this {@link io.netty.channel.SimpleChannelInboundHandler}
     *            belongs to
     * @param msg the message to handle
     * @throws Exception is thrown if an error occurred
     */
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, DefaultHttpContent msg) throws Exception {
        System.out.println("收到的请求的内容体是"+new String(ByteBufUtil.getBytes(msg.content())));
    }
}
